/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logiclander.whozwho.core;

import static com.google.common.base.Predicates.not;
import static com.google.common.base.Predicates.or;

import com.google.common.base.CharMatcher;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;

/**
 *
 * @author logiclander
 */
public class StringPredicates {

  public static final Predicate<String> IS_BLANK =
          matchesAllOf(CharMatcher.WHITESPACE);
  public static final Predicate<String> IS_NULL_OR_BLANK =
          or(Predicates.isNull(), IS_BLANK);
  public static final Predicate<String> IS_NOT_NULL_OR_BLANK =
          not(IS_NULL_OR_BLANK);

  public static Predicate<String> matchesAllOf(final CharMatcher charMatcher) {
    return new Predicate<String>() {

      @Override
      public boolean apply(String string) {
        return charMatcher.matchesAllOf(string);
      }
    };
  }
}
